package com.neuedu.methods;

public class MethodKindArgs {

    public static void main(String[] args) {

        int numa = 10,numb=5 ,numc=2 ,numd=10;

        sum(numa,numb);
        sum(1,2,3);
        sum(1,2,3,10,20,30);

        String name = "金山";
        int age = 18;
        double salary = 999999.99;
        System.out.printf("我是"+name+"，我今天"+18+"\r\n");
        System.out.printf("我是%s，我今天%d,薪水:%f",name,age,salary);


    }


    public static void sum(int numa , int numb){
        int result = numa + numb;
        System.out.println("result:"+result);
    }

    /**
     * otherNums 可变长参数
     * @param numa
     * @param numb
     * @param numc
     * @param otherNums   数组  int 只能放到方法 最后 最多只能有一个
     */
    public static void sum(int numa , int numb,int numc,int... otherNums){
        int result = numa + numb + numc;
        if(otherNums.length>0){
            for (int i = 0; i < otherNums.length; i++) {
                result+= otherNums[i];
            }
        }
        System.out.println("result:"+result);
    }
}
